<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>查看业绩</title>
    </head>
    <body>
        <div id="performance_form">
        </div>
        <div id="performanceGrid" class="x-form-item">
        </div>
        <script>
            var performance_ds; //数据源
            Ext.onReady(function(){
                var fromDate = new Ext.form.DateField({
                    fieldLabel: '统计日期从',
                    name: 'from_date',
                    id: 'from_date',
                    //altFormats: 'Y-m-d',
                    format: 'Y-m-d', //格式化日期
                    //disabledDays: [0,6],	//不让选择周六，周日
                    //disabledDaysText: "周末要休息",
                    invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
                    allowBlank: false,
					blankText: '开始日期必须选择',
                    //emptyText: '请选择...',
                    inputType: '2008-01-01',
                    //applyTo: 'from_date',
                    //anchor: '80%',
                    vtype: 'daterange',
                    endDateField: 'to_date',
                    width: 90
                    //,value: today                
                });
                
                var toDate = new Ext.form.DateField({
                    fieldLabel: '到',
                    name: 'to_date',
                    id: 'to_date',
                    //altFormats: 'Y-m-d',
                    format: 'Y-m-d', //格式化日期
                    //disabledDays: [0,6],	//不让选择周六，周日
                    //disabledDaysText: "周末要休息",
                    invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
                    allowBlank: false,
					blankText: '截止日期必须选择',
                    //emptyText: '请选择...',
                    inputType: '2008-01-01',
                    //applyTo: 'to_date',
                    //anchor: '80%',
                    vtype: 'daterange',
                    startDateField: 'from_date',
                    width: 90
                    //,value: today                
                });
                
                var queryButton = new Ext.Button({
                    text: '查 询',
                    handler: function(){
						if (formPanel.form.isValid()) {
							var from = fromDate.getValue().format('Y-m-d');
							var to = toDate.getValue().format('Y-m-d');
							performance_ds.baseParams.from_date = from;
							performance_ds.baseParams.to_date = to;
							performance_ds.reload();
						}
					}
                })
                
                var formPanel = new Ext.form.FormPanel({
                    //baseCls: 'x-plain',
                    labelWidth: 75,
                    width: '100%',
                    frame: true,
                    labelAlign: 'right',
                    items: [{
                        layout: 'column',
                        border: false,
                        items: [{
                            columnWidth: .2,
                            layout: 'form',
                            border: false,
                            items: [fromDate]
                        }, {
                            columnWidth: .2,
                            layout: 'form',
                            border: false,
                            items: [toDate]
                        }, {
                            columnWidth: .5,
                            layout: 'form',
                            border: false,
                            items: [queryButton]
                        }]
                    }]
                });
                
                formPanel.render('performance_form');
                
                //############## Grid ##############
                var performance_cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
                    header: '工号',
                    dataIndex: 'no',
                    width: 80
                }, {
                    header: '姓名',
                    dataIndex: 'name',
                    width: 100
                }, {
                    header: '订单数',
                    dataIndex: 'order_sum',
                    width: 80
                }, {
                    header: '已出票订单数',
                    dataIndex: 'out_order_sum',
                    width: 80
                }, {
                    header: '已出票张数',
                    dataIndex: 'out_ticket_sum',
                    width: 80
                }, {
                    header: '取消单数',
                    dataIndex: 'cancel_sum',
                    width: 80
                }, {
                    header: '保险张数',
                    dataIndex: 'insurance_sum',
                    width: 80
                }, {
                    header: '退票单数',
                    dataIndex: 'refund_sum',
                    width: 80
                }, {
                    header: '作废单数',
                    dataIndex: 'del_sum',
                    width: 80
                
                }]);
                
                //隐藏
                //performance_cm.setHidden(1, !performance_cm.isHidden(1));
                performance_ds = new Ext.data.Store({
                    proxy: new Ext.data.HttpProxy({
                        url: '/orders/getPerformance'
                    }),
                    reader: new Ext.data.JsonReader({
                        totalProperty: 'totalProperty',
                        root: 'root'
                    }, [{
                        name: 'no'
                    }, {
                        name: 'name'
                    }, {
                        name: 'order_sum'
                    }, {
                        name: 'out_order_sum'
                    }, {
                        name: 'out_ticket_sum'
                    }, {
                        name: 'cancel_sum'
                    }, {
                        name: 'insurance_sum'
                    }, {
                        name: 'refund_sum'
                    }, {
                        name: 'del_sum'
                    
                    }])
                });
                
                var ordergridpanel = new Ext.grid.GridPanel({
                    el: 'performanceGrid',
                    ds: performance_ds,
                    cm: performance_cm,
                    //sm: sm,
                    loadMask: true,
                    autoWidth: true,
                    collapsible: true,
                    animCollapse: true,
                    height: 500,
                    //frame: true,
                    title: '业绩信息'
                
                });
                
                ordergridpanel.render();
                performance_ds.load();
                
            })
        </script>
    </body>
</html>
